﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace Legend.Core.Tests.Integration
{
    [TestFixture]
    public class DefaultRandomNumberGeneratorIntegrationTests
    {
        private DefaultRandomNumberGenerator generator;

        [SetUp]
        public void SetUp()
        {
            this.generator = new DefaultRandomNumberGenerator();
        }

        [Test]
        public void GenerateRandomInteger_should_produce_random_values()
        {
            // Arrange
            var values = new LinkedList<int>();

            // Act
            for (int i = 0; i < 100; i++)
            {
                values.AddLast(this.generator.GetRandomInteger(0, 100));
            }

            // Assert
            Assert.That(values.Distinct().Count(), Is.GreaterThan(50));
        }

        [Test]
        public void GenerateRandomInteger_should_produce_different_values_when_only_two_values_are_possible()
        {
            // Arrange
            var values = new LinkedList<int>();

            // Act
            for (int i = 0; i < 100; i++)
            {
                values.AddLast(this.generator.GetRandomInteger(1, 2));
            }
            
            // Assert
            Assert.That(values.Where(x => x == 1).Count(), Is.GreaterThan(20).And.LessThan(80));
        }

        [Test]
        public void GetRandomFloatingPointNumber_should_produce_random_numbers()
        {
            // Arrange
            var values = new LinkedList<double>();

            // Act
            for (int i = 0; i < 100; i++)
            {
                values.AddLast(this.generator.GetRandomFloatingPointNumber());
            }

            // Assert
            Assert.That(values.Distinct().Count(), Is.GreaterThan(50));
        }
    }
}
